class Solution(object):
    def decodeCiphertext(self, encodedText, rows):
        n = len(encodedText)
        width = n // rows
        st = []
        for j in range(width):
            k = 0
            while k < rows and k + j < width:
                st.append(encodedText[k * width + k + j])
                k += 1
        s = ''.join(st)
        index = len(s) - 1
        while index >= 0 and s[index] == ' ':
            index -= 1
        return s[:index + 1]
